﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace KEEPER_BRR_13dotNET.Presentation
{
    public delegate bool CanAccept(string inputValue);
    public partial class Frm_InputSoGpKd : KP_CommonLibrary.KP_CommonControls.KP_FormBase01
    {
        public CanAccept CanAccept;
        public Frm_InputSoGpKd()
        {
            InitializeComponent();
        }
        public string Ma_Hs { get {
            txtSo_Gp.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
            string maHs= txtSo_Gp.Text;
            txtSo_Gp.TextMaskFormat = MaskFormat.IncludeLiterals;
            return maHs;
        } }

        private void btnAccept_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            if (string.IsNullOrEmpty(txtSo_Gp.Text))
            {
                errorProvider1.SetError(txtSo_Gp, "Chưa nhập số giấy phép kinh doanh");
                return;
            }
            if (CanAccept == null || (CanAccept != null && CanAccept(txtSo_Gp.Text)))
                DialogResult = DialogResult.OK;
            else
            {
                txtSo_Gp.Focus();
                txtSo_Gp.SelectionStart = 4;
                txtSo_Gp.SelectionLength = txtSo_Gp.Text.Length - 4;
                
            }
        }

        private void Frm_InputSoGpKd_Load(object sender, EventArgs e)
        {
            // txtSo_Gp.SelectionStart = 4;
            // txtSo_Gp.SelectionLength = 0;
        }
    }
}
